

const path = require('path');
const staticImg = path.join(__dirname, 'static');

function SensorbitUnoBlocks(Blockly) {
    var color_sensor = "#28BFE6";



    //温湿度传感器
    Blockly.Blocks.microbit_DHT11 = {
        init:function(){
            this.setColour(color_sensor);
            this.appendDummyInput("")
        .appendField(new Blockly.FieldImage(staticImg+"/12.Temperature   and humidity  sensor.svg", 84, 42))
            .appendField(Blockly.Msg.MICROBIT_DHT11)
            .appendField(new Blockly.FieldDropdown([
                ['P0', "pin0"],
                ['P1', "pin1"],
                ['P2', "pin2"],
                ['P8', "pin8"],
                ['P12', "pin12"],
                ['P13', "pin13"],
                ['P14', "pin14"],
                ['P15', "pin15"],
            ]),"dht11Port")
            this.appendDummyInput("")
            .appendField(Blockly.Msg.MICROBIT_DHT11GET)
            .appendField(
            new Blockly.FieldDropdown([
                [Blockly.Msg.MICROBIT_TEMPERATURE, "temperature()"],
                [Blockly.Msg.MICROBIT_HUMIDITY, "humidity()"],
            ]),"dnt11Func")
            this.appendDummyInput("")
            // .appendField(Blockly.Msg.MICROBIT_ANALOG)
        this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
            this.setOutput(true, 'Number');
            this.setTooltip('');
        }
    };


    return Blockly;
}

module.exports = SensorbitUnoBlocks;

